<?php
/**
 * Created by 无所谓已
 * User: Administrator
 * Date: 2025-09-20
 * Time: 10:36
 */

namespace plugin\csauto\app\controller;

use plugin\csauto\app\common\BaseController;
use plugin\csauto\app\model\RssModel;
use plugin\csauto\app\model\SiteRulesModel;
use support\Request;
use support\Response;

class RulesController extends BaseController
{

    /**
     * @var SiteRulesModel
     */
    protected $model = null;

    /**
     * 构造函数
     *
     * @return void
     */
    public function __construct()
    {
        $this->model = new SiteRulesModel;
    }

    public function index(Request $request)
    {
        return view('rules/index');
    }


    public function insert(Request $request): Response
    {
        if ($request->method() === 'POST') {
            return parent::insert($request);
        }
        return view('rules/insert');
    }


    public function update(Request $request): Response
    {
        if ($request->method() === 'POST') {
            return parent::update($request);
        }
        return view('rules/update');
    }

    public function select(Request $request)
    {
        [$where, $format, $limit, $field, $order] = $this->selectInput($request);
        $field = 'sort';
        $order = 'desc';
        $query = $this->doSelect($where, $field, $order);
        return $this->doFormat($query, $format, $limit);
    }
}